//
//  GHBusinessViewController.m
//  GodHorses
//
//  Created by Mac on 2017/11/14.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "GHRebateViewController.h"
#import "GHReateTableViewCell.h"
#import "GHOrderRebeatTableViewCell.h"
@interface GHRebateViewController ()

/**
 消费总额
 */
@property(nonatomic, strong) STLabel                     *allUselable;

/**
 累计返利
 */
@property(nonatomic, strong) STLabel                     *allGurdlable;
@end

@implementation GHRebateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"分红返利";
    [self configSubView];
    // Do any additional setup after loading the view.
}

#pragma mark --subView
- (void)configSubView{
    self.tableView.backgroundColor = GH_backgroundColor;
    UIView * tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 222)];
    tableHeaderView.backgroundColor = self.tableView.backgroundColor;
    UIImageView * bannerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 222)];
    bannerImageView.image = [UIImage imageNamed:@"img_fanli_banner"];
    [tableHeaderView addSubview:bannerImageView];
    
    UIView  * whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, bannerImageView.st_bottom + 10, UIScreenWidth, 60)];
    whiteView.backgroundColor = [UIColor whiteColor];
    [whiteView st_showBottomLineAndWitdh:whiteView.st_width];
    [tableHeaderView addSubview:whiteView];
    
    STButton * fenxiaoButton = [[STButton alloc] initWithFrame:CGRectMake(10, 10, 120, 17)
                                                         title:@"我的消费"
                                                    titleColor:GH_firstTextColor
                                                     titleFont:15
                                                  cornerRadius:0
                                               backgroundColor:nil
                                               backgroundImage:nil
                                                         image:[UIImage imageNamed:@"PC_tixianjilu"]];
    fenxiaoButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 00, 0);
    [whiteView addSubview:fenxiaoButton];
    
    
    UIView  * twoWhiteView = [[UIView alloc] initWithFrame:CGRectMake(0, whiteView.st_bottom, UIScreenWidth, 70)];
    twoWhiteView.backgroundColor = [UIColor whiteColor];
    [tableHeaderView addSubview:twoWhiteView];
    //总额
    STLabel * moneyLable = [[STLabel alloc] initWithFrame:CGRectMake(0,   10 , UIScreenWidth / 2, 15)
                                                     text:@"总额"
                                                textColor:GH_firstTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentCenter];
    moneyLable.st_centerX = UIScreenWidth /4;
    [twoWhiteView addSubview:moneyLable];
    self.allUselable  = [[STLabel alloc] initWithFrame:CGRectMake(0, moneyLable.st_bottom + 10, UIScreenWidth / 2, 15)
                                                  text:@"3000"
                                             textColor:GH_YellowBackGroundColor
                                                  font:14
                                           isSizetoFit:NO
                                         textAlignment:NSTextAlignmentCenter];
    self.allUselable.st_centerX = UIScreenWidth / 4;
    [twoWhiteView addSubview:self.allUselable];
    //累计返利
    STLabel * gurdLable = [[STLabel alloc] initWithFrame:CGRectMake(0,  10 , UIScreenWidth / 2, 15)
                                                    text:@"累计返利"
                                               textColor:GH_firstTextColor
                                                    font:14
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentCenter];
    gurdLable.st_centerX = 3 * UIScreenWidth /4;
    [twoWhiteView addSubview:gurdLable];
    self.allGurdlable  = [[STLabel alloc] initWithFrame:CGRectMake(0, gurdLable.st_bottom + 10, UIScreenWidth / 2, 15)
                                                   text:@"30"
                                              textColor:GH_YellowBackGroundColor
                                                   font:14
                                            isSizetoFit:NO
                                          textAlignment:NSTextAlignmentCenter];
    self.allGurdlable.st_centerX = 3 * UIScreenWidth /4;
    [twoWhiteView addSubview:self.allGurdlable];
    //线
    UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0,  10, 1, 45)];
    line.backgroundColor = GH_lineColor;
    line.st_centerX = UIScreenWidth / 2;
    [twoWhiteView addSubview:line];
    
    tableHeaderView.st_height = twoWhiteView.st_bottom ;
    self.tableView.tableHeaderView = tableHeaderView;
}
- (UIView*)sectionHeaderView{
    UIView * sectionHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 110)];
    sectionHeader.backgroundColor = self.tableView.backgroundColor;
    UIView * whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, UIScreenWidth, 50)];
    whiteView.backgroundColor = [UIColor whiteColor];
    [whiteView st_showBottomLineAndWitdh:whiteView.st_width];
    [sectionHeader addSubview:whiteView];
    //订单
    STButton * orderButton = [[STButton alloc] initWithFrame:CGRectMake(10, 10, 120, 17)
                                                         title:@"历史订单"
                                                    titleColor:GH_firstTextColor
                                                     titleFont:15
                                                  cornerRadius:0
                                               backgroundColor:nil
                                               backgroundImage:nil
                                                         image:[UIImage imageNamed:@"PC_xiaofeijilu"]];
    orderButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 00, 0);
    [whiteView addSubview:orderButton];
    
    UIView * titleView = [[UIView alloc] initWithFrame:CGRectMake(0, whiteView.st_bottom , UIScreenWidth, 50)];
    titleView.backgroundColor = [UIColor whiteColor];
    [sectionHeader addSubview:titleView];
    [titleView st_showBottomLineAndWitdh:whiteView.st_width];
    
    //标题
    CGFloat lableWith = UIScreenWidth / 4;
    UILabel * numLable = [self defultLableTitle:@"时间" showRigthLine:YES];
    numLable.st_left = 0;
    [titleView addSubview:numLable];
    UILabel * allUserLable = [self defultLableTitle:@"产品名称" showRigthLine:YES];
    allUserLable.st_left = 0 + lableWith;
    [titleView addSubview:allUserLable];
    UILabel * todayLable = [self defultLableTitle:@"价格" showRigthLine:YES];
    todayLable.st_left = 0 + 2 *lableWith;
    [titleView addSubview:todayLable];
    UILabel * allLable = [self defultLableTitle:@"今日返利" showRigthLine:NO];
    allLable.st_left = 0 + 3 *lableWith;
    [titleView addSubview:allLable];
    
    return sectionHeader;
}
- (UILabel*)defultLableTitle:(NSString*)title showRigthLine:(BOOL)showRigthLine{
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth / 4, 50)
                                                     text:title
                                                textColor:GH_firstTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentCenter];
    if (showRigthLine) {
        [titleLable st_showRightLine:50];
    }
    return titleLable;
    
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1 ;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 4;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 110;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * sectionHeader = [self sectionHeaderView];
    return sectionHeader;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    GHOrderRebeatTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[GHOrderRebeatTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}
#pragma mark --Action Method
- (void)onSelectedDetailButtonWithIndexPath:(NSIndexPath*)indexPath{
    
}
@end

